package com.zhanglijie.theory.ArrayListDemo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/7/21 0021 23:45
 */
public class UnsafeList {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        //修改操作
        new Thread(()->{
            for(int i=0;true;i++){
                list.add(i);
                list.remove(0);
            }
        }).start();
        //读操作
        new Thread(()->{
            Iterator<Integer> iterator = list.iterator();
            while (iterator.hasNext()){
                Integer next = iterator.next();
                System.out.println(next);
            }
        }).start();
    }
}
